<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 一周中的第几天
给你一个日期，请你设计一个算法来判断它是对应一周中的哪一天。
输入为三个整数：day、month 和 year，分别表示日、月、年。
您返回的结果必须是这几个值中的一个 {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}。
示例 1：
输入：day = 31, month = 8, year = 2019
输出："Saturday"
 -->
</head>

<body>
  <script>
    var dayOfTheWeek = function (day, month, year) {
      let date = year + "-" + month + "-" + day;
      //把获取的参数 拼接成日期字符串
      let a = new Date(date).getDay()
      //用日期对象识别一下这天是星期几 返回的就是下面数组的下标
      let d = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
      return d[a]
    };
    console.log(dayOfTheWeek(31, 8, 2019));
  </script>
</body>

</html>